package com.smartlbs.baseframe.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.web.context.support.WebApplicationContextUtils;

public class InitTask implements ServletContextListener {
	private static ServletContext servletContext = null; 
	
	public static ServletContext getServletContext(){
		return servletContext;
	}
	
	public static Object getSpringBean(String name){
		 return WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext).getBean(name);
	}
	
	public void contextInitialized(ServletContextEvent event){
		servletContext = event.getServletContext();	
	}
	
	public void contextDestroyed(ServletContextEvent event){
	}
}
